'use client'
import { Button } from "@nextui-org/react"
import { useState } from "react"

export default function ButtonType({
    list = [],
    onChange=()=>{}
}){
    const [isCheck, setIsCheck] = useState(0)
// 处理点击事件
    const handleClick = (index) => {
        setIsCheck(index)
        onChange && onChange(index)
    }
    return (
        <div className="buttonType flex justify-center">
            {
                list.map((item, index) => {
                    return <Button color={isCheck === index?'primary':'default'} key={index} className="buttonType-button mr-[17px] px-7 py-3 text-[14px]" radius="full" onClick={()=>handleClick(index)}>
                        {item.name}
                    </Button>
                })
            }
        </div>
    )
}